package util;

import Entity.FlowData;

public class MathUtil {

	public static void initial() {
		
	}
	
	public static FlowData gauss(FlowData flowData,int start,int length) {
		length = length>flowData.getLen()?flowData.getLen():length;
		FlowData f = new FlowData(length);
		f.setData(0,(short)((flowData.getData(start+1)-flowData.getData(start))/flowData.getStamp()));
		f.setData(length-1,(short)((flowData.getData(start+length-1)-flowData.getData(start+length-2))/flowData.getStamp()));	
		for(int i  = start+1 ; i < start+length-1 ; i++) {
			f.setData(i-start,(short)(int)((flowData.getData(i+1)-flowData.getData(i-1))/flowData.getStamp()/2));
		}
		f.minMax();
		return f;
	}
	
	public static FlowData sumup(FlowData flowData,int start,int length) {
		length = length>flowData.getLen()?flowData.getLen():length;
		FlowData f = new FlowData(length);
		f.setData(0,(short)(int)((flowData.getData(0)*flowData.getStamp())));
		for(int i  = start+1 ; i < start+length-1 ; i++) {
			f.setData(i-start,(short) (f.getData(i-start-1)+(short)(int)((flowData.getData(i)*flowData.getStamp()))));
		}
		f.minMax();
		return f;
	}
}
